{% extends "admin/base_site.html" %}
{% load i18n %}

{% block extrahead %}
    <script type="text/javascript">
        $(document).ready(function() {
            grappelli.initDateAndTimePicker();
        });
    </script>
    
    <script type="text/javascript">
	function options_toggle(id) {
            /*id must follow convenction toggle_model_action
             Ex id = toggle_student_filter */
            if ($('#' + id.split("_")[1] + '_' + id.split("_")[2]).is(':visible')) {
                $('#' + id).html('Show ' + id.split("_").slice(-2) );
            } else {
                $('#' + id).html('Hide ' + id.split("_").slice(-2));
            }
            $('#' + id.split("_")[1] + '_' + id.split("_")[2]).toggle('fast');
        }
    </script>
{% endblock %}

{% block content_title %}
    <h1>Grade Reports</h1>
{% endblock %}

{% block content %}
<form action="" method="post" enctype="multipart/form-data">
    <fieldset style="padding:5px;">
	<legend> Template based report </legend>
	{{ form.non_field_errors  }}
	<table>
	    <tr><td>
		<div class="grp-td date">
		    {{ form.date.label }} {{ form.date }} {{ form.date.errors }}
		</div>
		
		</td></tr><tr><td>
		<div>
		    {{ form.include_deleted.label }} {{ form.include_deleted }} {{ form.include_deleted.errors }}
		</div>
		<div>
		    {{ form.all_students.label }} {{ form.all_students }} {{ form.all_students.errors }}
		</div>
		<div>
		    {{ form.student.label }} {{ form.student }} {{ form.student.errors }}
		</div>
	    </td></tr><tr><td>
		<a href="#" id="toggle_filter_options" onclick='options_toggle(id)'>Show filter and sort options</a>
		<div id="filter_options" style="display: none">
		    {{ form.sort_by.label }}  {{ form.sort_by }} {{ form.sort_by.errors }}
		    <br/> {{ form.filter_year.label }}  {{ form.filter_year }} {{ form.filter_year.errors }}
			<br/> {{ form.filter_cohort.label }} {{ form.filter_cohort }} {{ form.filter_cohort.errors }}
		</div>
	    </td></tr><tr><td>
		<div>
		    {{ form.template.label }} {{ form.template }} {{ form.template.errors }}
		</div>
		<div>
		    {{ form.upload_template.label }} {{ form.upload_template }} {{ form.upload_template.help_text }} {{ form.upload_template.errors }}
		</div>
		{{ form.format.label }} {{ form.format }} {{ form.format.errors }}
		<input type="submit" name="student_grade" value="Generate Template Report"/>
	    </td>
	    </tr>
	    <tr>
		<td>
		    <input type="submit" name="date_based_gpa_report" value="GPAs per year"/>
		</td>
	    </tr>
	</table>
    </fieldset>
</form>
<br/>

<form action="" method="post" enctype="multipart/form-data">
    <fieldset style="padding:5px;">
	<legend> Grade Aggregate Reports </legend>
	{{ mp_form }}
	<br/>
	<input type="submit" name="aggregate_grade_report" value="Aggregated data on teachers and year"/>
	{% if 'ecwsp.grades' in settings.INSTALLED_APPS %}
	    <input type="submit" name="fail_report" value="Student failures by department"/>
	{% endif %}
    </fieldset>
</form>
{% endblock %}

